<?php

include_once("../../../common/module/checkA.php");
include_once("../../../../config.php");

?>


<?
//设置需要搜索的表格的前缀后缀
$table_suffix = 'term';
$table        = $table_Prefix . $table_suffix;
?>


<?php
$new_term_id            =addslashes($_REQUEST['term_term_id']);
//此段函数，根据获取过来的id，查询出所属分类的term1~term5，interm
if ($new_term_id == 'root') {
    $_REQUEST['ai_term0'] = 0;
    $_REQUEST['ai_interm'] = 'root';

} else {

    $result = mysql_query("select * from $table where nid = $new_term_id");
//根据ID,获取相应的所属分类资料
    while ($row = mysql_fetch_array($result)) {

        $ai_nid = $new_term_id;
        $_REQUEST['ai_term0'] = $row['term0'];
        $_REQUEST['ai_term1'] = $row['term1'];
        $_REQUEST['ai_term2'] = $row['term2'];
        $_REQUEST['ai_term3'] = $row['term3'];
        $_REQUEST['ai_term4'] = $row['term4'];
        $_REQUEST['ai_term5'] = $row['term5'];
        $_REQUEST['ai_interm'] = $row['interm'];
    }
//下面这个判断，选择root没问题，其他的if else要修改一下
    if ($_REQUEST['ai_interm'] == "root") {
        $_REQUEST['ai_term1'] = $new_term_id;
        $_REQUEST['ai_interm'] = "term1";
    } else if ($_REQUEST['ai_interm'] == "term1") {
        $_REQUEST['ai_term2'] = $ai_nid;
        $_REQUEST['ai_interm'] = "term2";
    } else if ($_REQUEST['ai_interm'] == "term2") {
        $_REQUEST['ai_term3'] = $ai_nid;
        $_REQUEST['ai_interm'] = "term3";
    } else if ($_REQUEST['ai_interm'] == "term3") {
        $_REQUEST['ai_term4'] = $ai_nid;
        $_REQUEST['ai_interm'] = "term4";
    } else if ($_REQUEST['ai_interm'] == "term4") {
        $_REQUEST['ai_term5'] = $ai_nid;
        $_REQUEST['ai_interm'] = "term5";
    }

}

?>


<?

//$_REQUEST['ai_authur']      = $_SESSION['username'];
//$_REQUEST['ai_ip']          = $_SERVER["REMOTE_ADDR"];

$icon['upfile']      = $_FILES['ai_icon'];

$icon['path']        = ROOT_PATH_ . "/uploadfiles/uf" . $site['mid'] . "/";
$_REQUEST['ai_icon'] = upload_file($icon)['name'];
$term_nid = $_REQUEST['term_nid'];

$sql = update_date($table,$_REQUEST,"nid",$term_nid);

sql_log($sql);

$query = mysql_query($sql) or die ('保存term表失败'.mysql_error());


mysql_close($con);

?>



<script type="text/javascript">

    alert("输入信息已保存，点击确认返回继续操作.");
    document.location.href = "term-list.php?now_extender=<? echo $system_part ?>";

</script>
